
#ifndef __CORTISOL_AVUTIL_H
#define __CORTISOL_AVUTIL_H

class AVUtilLib
{
	HMODULE handle;

	typedef void* (*av_malloc_fptr_t)(FF_INTERNAL_MEM_TYPE size); 
	av_malloc_fptr_t av_malloc_fptr;

	typedef void  (*av_free_fptr_t)(void *ptr);
	av_free_fptr_t av_free_fptr;

public:

	AVUtilLib() {

		Initialise();
	}

	virtual ~AVUtilLib() {

		CleanUp();
	}

	void* av_malloc(FF_INTERNAL_MEM_TYPE size) const {

		return av_malloc_fptr( size );
	}

	void av_free(void *ptr) const {

		return av_free_fptr( ptr );
	}

private:

	void Initialise() {

		if((handle = LoadLibrary( L"avutil-50.dll" )) == NULL)
			throw Exception("LoadLibrary( L\"avutil-50.dll\" )");

		RESOLVE(av_malloc);
		RESOLVE(av_free);
	}

	void CleanUp() {

		FreeLibrary( handle );
	}

};

#endif /*** __CORTISOL_AVUTIL_H ***/

